package autokeyboard.handler;

import javax.swing.JComboBox;
import javax.swing.JLabel;

//import autokeyboard.data.KeyData;

/**
 * This class is used to call all event in StartOption dialog
 * 
 * @author HoldTheHand
 * 
 */
@SuppressWarnings("rawtypes")
public class StartOptionEvent {

	private JLabel		lblStartKey;
	private JLabel		lblPauseKey;
	private JLabel		lblStopKey;
	private JLabel		lblStartAfter;

	private JComboBox	cbbStartKey;
	private JComboBox	cbbPauseKey;
	private JComboBox	cbbStopKey;
	private JComboBox	cbbStartAfter;
	
//	private KeyData keyData = new KeyData();

	public StartOptionEvent(JLabel lblStartKey, JLabel lblPauseKey, JLabel lblStopKey, JLabel lblStartAfter, JComboBox cbbStartKey, JComboBox cbbPauseKey, JComboBox cbbStopKey, JComboBox cbbStartAfter) {
		this.lblStartKey = lblStartKey;
		this.lblPauseKey = lblPauseKey;
		this.lblStopKey = lblStopKey;
		this.lblStartAfter = lblStartAfter;
		this.cbbStartKey = cbbStartKey;
		this.cbbPauseKey = cbbPauseKey;
		this.cbbStopKey = cbbStopKey;
		this.cbbStartAfter = cbbStartAfter;
	}

	/**
	 * This method is check whether one of your comboBox has the same index
	 */
	public void isSameIndexComponent(JComboBox cbbStartKey, JComboBox cbbPauseKey, JComboBox cbbStopKey) {
		if (cbbStartKey.getSelectedIndex() == cbbPauseKey.getSelectedIndex()) {
			setDefaultSelectedIndex(cbbStartKey, cbbPauseKey, cbbStopKey);
		}
		else if (cbbStartKey.getSelectedIndex() == cbbStopKey.getSelectedIndex()) {
			setDefaultSelectedIndex(cbbStartKey, cbbPauseKey, cbbStopKey);
		}
		else if (cbbPauseKey.getSelectedIndex() == cbbStopKey.getSelectedIndex()) {
			setDefaultSelectedIndex(cbbStartKey, cbbPauseKey, cbbStopKey);
		}
	}

	/**
	 * This method will reset all your comboBox selected index to default
	 * 
	 * @param cbbStartKey
	 * @param cbbPauseKey
	 * @param cbbStopKey
	 */
	private void setDefaultSelectedIndex(JComboBox cbbStartKey, JComboBox cbbPauseKey, JComboBox cbbStopKey) {
		cbbStartKey.setSelectedIndex(0);
		cbbPauseKey.setSelectedIndex(1);
		cbbStopKey.setSelectedIndex(2);
	}
	
	/**
	 * This method will set Enabled or Disabled for some component with your
	 * input boolean value
	 * 
	 * @param value
	 */
	public void setEnabledComponentUseHotKey(boolean value) {
		lblStartKey.setEnabled(value);
		lblPauseKey.setEnabled(value);
		lblStopKey.setEnabled(value);

		cbbStartKey.setEnabled(value);
		cbbPauseKey.setEnabled(value);
		cbbStopKey.setEnabled(value);

		lblStartAfter.setEnabled(!value);
		cbbStartAfter.setEnabled(!value);
	}
	
	
	
	
}
